home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
comm
/
yep16.zip
/
YX-13.ZIP
/
ROT13.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-11-20
|
859b
|
38 lines
/* simple ROT13 encode/decode a file from stdin to stdout
usage: rot13 <input.txt >output.txt
*/
if lines() = 0 then do
say sourceline(3)
exit
end
do while lines() > 0
say translate(linein(),'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
/* commented out below is the standard way of doing it. I had forgotten about
the handy REXX "translate" function which speeds things up greatly! */
/* t = ''
l = linein()
do x = 1 to length(l)
c = substr(l,x,1);
if ((c>='a')&(c<='z'))|((c>='A')&(c<='Z')) then do
d = c2d(c)
select
when d>=110 then d = d - 13
when d>=97 then d = d + 13
when d>=78 then d = d - 13
otherwise d = d + 13
end
c = d2c(d)
end
t = t || c
end;
say t */
end;